<template>
	<view class="">
		<view>
			<!-- 			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-red">{{task.name}}</text>
				</view>
			</view> -->
			<van-cell-group>
				<van-field :value="formData.content" @input="input($event,'content')" placeholder="请输入评论" required
					clearable />
				<van-field :value="formData.score" @input="input($event,'score')" placeholder="请输入成绩" required clearable
					autosize />
			</van-cell-group>
			<!-- 			<van-divider /> -->
			<!-- 			<ccPicker class="item" :range="stuList" k="name" v="id"  v-model="formData.stuId"
				@picker_change="stu_change"></ccPicker> -->
			<van-goods-action>
				<van-goods-action-button text="提交评论" @click="submit()" />
			</van-goods-action>
		</view>
	</view>
</template>

<script>
	import ccPicker from '../../components/cc-picker/cc-picker.vue'
	export default {
		components: {
			ccPicker
		},
		data() {
			return {
				formData: {
					content: '',
					score: '',
					stuId: '',
					teaId: '',
					execId: ""
				},
				stuList: []
			}
		},
		created() {
			// this.getStu()
		},
		onLoad(option) {
			
			this.formData.stuId = option.stuId
			this.formData.execId = option.execId
		},
		methods: {
			// getStu() {
			// 	//this.$refs.form.submit().then(res => {
			// 		uni.request({
			// 			url: 'http://localhost:8082/task_admin/student/queryStu?pageNum=1&pageSize=100',
			// 			success: (res) => {
			// 				console.log(res)
			// 				if (res.data.code == 200) {
			// 					this.stuList = res.data.data
			// 				}
			// 			}
			// 		});
			// 	// }).catch(err => {
			// 	// 	console.log('表单错误信息：', err);
			// 	// })
			// },
			// 提交
			submit() {
				let ww = uni.getStorageSync('teaId')
				this.formData.teaId = (ww == null ? 1 : ww)
				//this.$refs.form.submit().then(res => {
				uni.request({
					url: 'http://localhost:8082/task_admin/evaluate/add',
					data: this.formData,
					method: "POST",
					dataType: "json",
					success: (res) => {
						console.log(res)
						if (res.data.code == 200) {
							uni.navigateTo({
								url: '/pages/teacher/evaluate-list'
							});
						} else {
							uni.showToast({
								title: "已经评论过"
							})
						}
					}
				});
				// }).catch(err => {
				// 	console.log('表单错误信息：', err);
				// })
			},
			input(event, name) {
				let {
					detail
				} = event;
				this.formData[name] = detail;
			},
			stu_change(e) {
				this.formData.stuId = e.new_v;
			}
		}
	}
</script>

<style>
</style>
